<div class="jxksHisksMap" >
    <div class="jxksHisksMap-left">
        <div class="jxksHisksMap-left-title">绩效科室列表</div>
        <div class="jxksHisksMap-left-content">
            <ul id="tt"></ul>
        </div>
    </div>
    <div class="jxksHisksMap-right">
        <div class="jxksHisksMap-right-top">
            <div class="jxksHisksMap-right-top-title">
                指标列表
                <span style="padding-top: 4px;height: 40px;float: right;padding-right: 20px;">
                    <input id="khzq" name="dept">
                </span>
                <span style="height:40px;line-height: 40px;float: right;padding-right: 5px;font-size:14px;">考核账期:</span>
            </div>
            <div class="jxksHisksMap-right-grid">
                <table id="dg" class="easyui-datagrid" style="width:100%;">
                    <!--<thead>-->
                    <!--<tr>-->
                    <!--<th  width="15%">Item ID(15%)</th>-->
                    <!--<th  width="15%">Product(15%)</th>-->
                    <!--<th  width="15%">List Price(15%)</th>-->
                    <!--<th  width="15%">List Price(15%)</th>-->
                    <!--<th width="15%">List Price(15%)</th>-->
                    <!--</tr>-->
                    <!--</thead>-->
                </table>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    var dHeight = $(".jxksHisksMap").height()-42;
    var jxksgsmb={
        init:function () {
            this.initEvents();
            this.initJxksTree();
            this.initKhzq();
            this.initGrid();

        },
        initEvents:function () {

            var that = this;

            $(".jxksgsmb-right-top-bottom").on("click",".jxksgsmb-gs-item",function () {
                $(this).addClass("active").siblings().removeClass("active")
            })

            $(".hrp-btn-delete").click(function () {
                if( $(".jxksgsmb-right-top-bottom").children(".active").length){
                    $(".jxksgsmb-right-top-bottom").children(".active").remove();
                }else{
                    $.messager.show({
                        title:'消息提醒',
                        msg:'请选择要删除的项目',
                        timeout:1000,
                        showType:'slide'
                    });
                }
            })

            $(".hrp-btn-add").on("click",function () {
                that.updateGs();
            })

            $(document).on("click",".zbChecked",function () {

                alert("ss");
            }).on("change",".zbValue",function () {



                var zbdm = $(this).attr("data-zbdm");
                var value = $(this).val();
                var jxksdm = $('#tt').tree("getSelected").id;
                var zqid = $('#khzq').combobox("getValue");

                $.post("/jxkhzb/saveZbValueByJxksdmAndZqidAndZbid",{"zbdm":zbdm,"value":value,"jxksdm":jxksdm,"zqid":zqid},function () {

                })


            })


        },
        initKhzq:function () {
            var that = this;
            $('#khzq').combobox({
                url:"common/getKhzqList",
                valueField:'id',
                textField:'text',
                onSelect:function (record) {
                    that.initGrid(record.id);
                },
                onLoadSuccess:function () {

                }
            });
        },
        initJxksTree:function () {

            var that = this;

            $('#tt').tree({
                url:"/common/getJxksTree",
                onClick:function (node) {
                    var jxksdm = node.id;
                    var zqid = $('#khzq').combobox("getValue");
                    //var zqid = zqNode.id;
                    jxksgsmb.initGrid(jxksdm,zqid);
                },
                animate:true
            });
            return that;
        },
        initGrid:function (jxksdm,zqid) {
            $('#dg').datagrid({
                url: "jxkhzb/getZbListByZqidAndJxksdm",
                //pagination: true,
                singleSelect: true,
                height:dHeight,   //表格高度，可指定高度，可自动
                //pageNumber: 1,
                //pageSize: 15,
                //pageList: [15, 30],
                queryParams: {
                    jxksdm:jxksdm,
                    zqid: zqid
                },
                loadMsg: "正在加载数据",
                nowrap: false,
                striped: true,  //奇偶行是否使用不同的颜色
                columns:[
                    [
                        {field:'isChecked',title:'选择',width:"10%",
                            formatter: function(value,row,index) {
                                if(value==-1){
                                    return "<input class='zbChecked' type='checkbox' checked='false' data-value='"+row.id+"'/>"
                                }else{
                                    return "<input class='zbChecked'  type='checkbox' checked='true'  data-value='"+row.id+"'/>"
                                }
                            }
                        },
                        {field:'id',title:'编号',width:"10%"},
                        {field:'zbdm',title:'指标代码',width:"10%"},
                        {field:'zbmc',title:'指标名称',width:"20%"},
                        {field:'cloumName',title:'指标别名',width:"20%"},
                        {field:'sjly',title:'数据来源',width:"10%"},
                        {field:'value',title:'实际值',width:"20%",
                            formatter: function(value,row,index) {
                                return "<input value='" + value + "' class='zbValue'  data-zbdm='"+row.zbdm+"'/>"
                            }
                        }
                    ]
                ]

            });

        },
        initKslb:function () {
            var that = this;
            $('#kslb').combobox({
                url:"common/getKslbList",
                valueField:'id',
                textField:'text',
                onSelect:function (record) {
                    that.initGrid(record.id);
                },
                onLoadSuccess:function () {

                }
            });
        }
    }

    $(function () {
        jxksgsmb.init();
    })

</script>